﻿using Net5ApiANdWpfClient.Lib.Common;
using Net5ApiANdWpfClient.Lib.Model;
using Net5ApiANdWpfClient.Lib.Model.SystemAdmin;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Net5ApiANdWpfClient.Lib.Service
{
    public class ModuleService
    {
        private static List<ModuleView> menuList;
        public static List<ModuleView> MenuList
        { get {
                if (menuList == null) menuList = GetModuleViewsAll();
                return menuList;
            }  }
        public static List<ModuleView> GetModuleViewsAll()
        {
            List<ModuleView> modulesList = new List<ModuleView>();
            //ModuleView topView = new ModuleView()
            //{
            //    module_code = "system_top",
            //    module_name = "Wpf系统"
            //};
         //   modulesList.Add(topView);
          //  topView.SonModuleList = new List<ModuleView>();

            ModuleView moduleMnager = new ModuleView()
            {
                module_code = "module_manager",
                module_name = "模块管理"
            };
            modulesList.Add(moduleMnager);

            ModuleView roleManager = new ModuleView()
            {
                module_code = "role_manager",
                module_name = "角色管理"
            };
            roleManager.SonModuleList = new List<ModuleView>();
            ModuleView roleManagerAdd = new ModuleView()
            {
                module_code = "role_manager_add",
                module_name = "角色添加"
            };
            roleManagerAdd.SonModuleList = new List<ModuleView>();
            roleManagerAdd.SonModuleList.Add(

                 new ModuleView()
                 {
                     module_code = "role_manager_add1",
                     module_name = "角色添加1"
                 }
                );
            roleManager.SonModuleList.Add(roleManagerAdd);

            modulesList.Add(roleManager);



            ModuleView userManager = new ModuleView()
            {
                module_code = "user_manager",
                module_name = "用户管理"
            };
            userManager.SonModuleList = new List<ModuleView>();

            userManager.SonModuleList.Add(new ModuleView()
            {
                module_code = "user_add",
                module_name = "用户列表",
                winform_type = "Net5ApiANdWpfClient.WpfClient.SystemManager.AdminUserManager"
            });
            userManager.SonModuleList.Add(new ModuleView()
            {
                module_code="user_add",
                module_name = "用户添加",
                winform_type = "Net5ApiANdWpfClient.WpfClient.SystemManager.AdminUserAdd"
            });
            modulesList.Add(userManager);

            return modulesList;


            //string apiUrl = "SystemAdmin/ModuleManager/GerModuleList"; //请求api的路径
            //ResultModel result = HttpRequestTools.GetByToken(apiUrl);
            //if (result.code == ResultCode.Ok)  //返回结果正确
            //{
            //    dynamic data = result.data;  //将数据返回给动态对象
            //    List<ModuleView> moduleList = JsonConvert.DeserializeObject<List<ModuleView>>(JsonConvert.SerializeObject(data));
            //    return moduleList;
            //}
            //else
            //{
            //    return new List<ModuleView>();
            //}
        }

       
    }
}
